A Practical Study of Control in Objected-Oriented-Functional-Logic Programming with Paisley

نویسندگان

  • Baltasar Trancón y Widemann
  • Markus Lepper
چکیده

ions, nondeterminism by backtracking, encapsulated search, and metaprogramming, without requiring changes to either the Java host language or the code of the data object models to be queried. In past papers, we have demonstrated how to use Paisley to sanitize legacy query interfaces [5], how to combine nondeterminism and search-plan metaprogramming to solve logical puzzles [7], and how to express complex relational queries in pattern (Kleene) algebra [8], respectively. In summary, Paisley turns Java into an effective functional–logic programming language, without constraining the use of features of the object-oriented host environment. However, the demonstrations have so far focused on encapsulated search, and omitted a different aspect that is ubiquitous in declarative pattern matching: the joint specification of data and control flow in case distinctions by pattern matching clauses. The present paper fills this gap. The Java language has adopted, in its recent version 8, mechanisms for local functional programming that are well-integrated with the object-oriented background. We demonstrate how to use these to encode the right hand sides of pattern matching clauses as continuations, such that the ordinary Java means for clause selection, namely conditional statements and short-circuiting Boolean operators, can be used freely and effectively. Unlike for the preceding papers [7, 8], we illustrate the real-world use of this novel expressivity not by constructing a new program for the purpose, but instead by reengineering parts of an existing third-party open-source project. We discuss and evaluate the impact of our modifications both qualitatively and quantitatively. 2 Paisley in a Nutshell As a running example, consider Figure 1 (left): a simple data model of LISP-style universal lists, implemented in Java in object-oriented textbook style. It is a simple matter to denote the construction of a list, for instance of three elements x, y and z. It is however a very different matter to use the public API to denote the inverse operation: checking whether a given list contains exactly three elements, and if so, extract them as x, y and z, or otherwise do something else. See Figure 2 (top and center). The style 152 Control for Paisley list1 = new Pair(x, new Pair(y, new Pair(z, empty) ) ); boolean success = false; // [S] if (list1 instanceof Pair) { // [T] Pair pair1 = (Pair)list1; // [C] Object x = pair1.getCar( ); // [B,P] Object list2 = pair1.getCdr( ); // [b,P] if (list2 instanceof Pair) { // [T] Pair pair2 = (Pair)list2; // [C] Object y = pair2.getCar( ); // [B,P] Object list3 = pair2.getCdr( ); // [b,P] if (list3 instanceof Pair) { // [T] Pair pair3 = (Pair)list3; // [C] Object z = pair3.getCar( ); // [B,P] Object list4 = pair3.getCdr( ); // [b,P] if (list4 == empty) { // [T] succeed(x, y, z); // [R] success = true; // [S]

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Interpreting XPath by Iterative Pattern Matching with Paisley

The Paisley architecture is a light-weight EDSL for non-deterministic pattern matching. It automates the querying of arbitrary objectoriented data models in a general-purpose programming language, using API, libraries and simple programming patterns in a portable and noninvasive way. The core of Paisley has been applied to real-world applications. Here we discuss the extension of Paisley by pat...

متن کامل

Signifying of the Urmia Lake Changes using Objected- Oriented Image Processing Techniques

The main aim of the present study was to map of Urmia Lake water surface diminishing rates over a long-term period, and demonstrating the most recent surface of emerged salty alluvial plains. For this purpose, Landsat TM, ETM+ and OLI imageries, observing from 1984 to 2015, were progressively processed to generate most of the thematic models in tempo-spatial context. All multi-date satellite da...

متن کامل

Dwarf Frankenstein is still in your memory: tiny code reuse attacks

Code reuse attacks such as return oriented programming and jump oriented programming are the most popular exploitation methods among attackers. A large number of practical and non-practical defenses are proposed that differ in their overhead, the source code requirement, detection rate and implementation dependencies. However, a usual aspect among these methods is consideration of the common be...

متن کامل

Experience With a Functional-Logic Multi-Agent Architecture for Medical Problem Solving

INTRODUCTION There exist various experiences in constructing applications in functional and logic languages alone as reported, e.g., in the conference series Lisp and Functional Programming and Practical Applications of Prolog, respectively. Applications in integrated functional-logic languages (Hanus, 1994) have been less frequent, however, and little has been reported about experiences with t...

متن کامل

Design and PLC Implementation for Speed Control of DC Motor using Fuzzy Logic

In this article, a speed control of DC motor is designed and illustrated using fuzzy logic-based programmable logic controller (PLC). The DC motor is an attractive part of electrical equipment in many industrial applications requiring variable speed and load specifications due to its ease of controllability. The designed system is consisted of three main parts including programmable logic contr...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2017